package cn.itsource.autoconfigure;

import cn.dev33.satoken.jwt.StpLogicJwtForStateless;
import cn.dev33.satoken.stp.StpLogic;
import cn.itsource.config.RedisConfig;
import cn.itsource.config.SaTokenConfigure;
import cn.itsource.config.StpInterfaceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

@Configuration
@Import(RedisConfig.class)
public class SaTokenAutoConfiguration {



    // Sa-Token 整合 jwt (Stateless 无状态模式)
    @Bean
    public StpLogic getStpLogicJwt() {
        return new StpLogicJwtForStateless();
    }
    @Bean
    public SaTokenConfigure getSaTokenConfigure(){
        return new SaTokenConfigure();
    }

    @Bean
    public StpInterfaceImpl getStpInterfaceImpl(RedisTemplate<String,Object> redisTemplate){
        return new StpInterfaceImpl(redisTemplate);
    }

    @Bean
    public BCryptPasswordEncoder getBCryptPasswordEncoder(){
        return new BCryptPasswordEncoder();
    }


}
